package serializer

// Response 基础序列化器
type Response struct {
	Code    int         `json:"code"`
	Data    interface{} `json:"data,omitempty"`
	Message string      `json:"msg"`
	Error   string      `json:"error,omitempty"`
}

// DataList 基础列表结构
type DataList struct {
	TodoList     interface{} `json:"todo_list"`
	Total        uint        `json:"total"`
	HistoryTotal uint        `json:"history_total"`
}

// BuildListResponse 序列化列表结构
func BuildListResponse(items interface{}, total uint, history uint) Response {
	return Response{
		Code: 0,
		Data: DataList{
			TodoList:     items,
			Total:        total,
			HistoryTotal: history,
		},
		Message: "获取事项列表成功",
	}
}
